package com.bjpowernode.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class UserController {

    @RequestMapping(value = "/user/detail")
    public String message(Model model){
        model.addAttribute("message","SpringBoot Thymeleaf");
        return "detail";
    }

    @RequestMapping(value = "/url")
    public ModelAndView url(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("id",1002);
        mv.setViewName("detail");
        return mv;
    }

    @RequestMapping(value = "/text")
    public @ResponseBody String text(){
        return "111";
    }

    @RequestMapping(value = "/text/{id}")
    public @ResponseBody String text1(@PathVariable("id") Integer id){
        return "id=" + id;
    }

}
